﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using FastReport;

namespace SmallERP.FenPian.Forms
{
    public partial class FrmShowPaperCode : Form
    {
        public List<PhotoDict> PhotoDict { get; set; }
        public FrmShowPaperCode(Dictionary<int,int> inDict)
        {
            InitializeComponent();
            PhotoDict=new List<PhotoDict>();
            foreach (KeyValuePair<int, int> i in inDict)
            {
                PhotoDict.Add(new PhotoDict(){PhotoId = i.Key,WasteID =i.Value});
            }
        }

        private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            if (e.Info.IsRowIndicator)
            {
                if (e.RowHandle>-1)
                {
                    e.Info.DisplayText = (e.RowHandle + 1).ToString();
                }
            }
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            Report rp = new Report();
            rp.Load(Application.StartupPath+"\\Report\\相纸条码.frx");
           rp.PrintSettings.ShowDialog = false;
          foreach (PhotoDict pId in PhotoDict)
            {
                rp.SetParameterValue("pId", "*"+pId.WasteID+"*");               
                rp.Print();
            }
        }

        private void FrmShowPaperCode_Load(object sender, EventArgs e)
        {
            if (PhotoDict != null && PhotoDict.Count > 0)
            {
                gridControl1.DataSource = PhotoDict;
            }
        }
    }
    public class PhotoDict

{
        public int PhotoId { get; set; }
        public int WasteID { get; set; }
}
}
